﻿using UML_Creator.Model;
using GalaSoft.MvvmLight.Command;
using System;
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Diagnostics;

namespace UML_Creator.Command
{
    // Bruges til at tilføje punkt til punkt samlingen.
    
    public class AddNodeCommand : IUndoRedoCommand
    {
        private ObservableCollection<Diagram> nodes;
        // TODO Fix controls for adding diagram
        private Diagram node;
        private int diagramType;

        public AddNodeCommand(ObservableCollection<Diagram> _nodes, int _diagramType) { nodes = _nodes; diagramType = _diagramType; }

        public void Execute()
        {
            if (diagramType == (int)UML_Creator.ViewModel.EnumDiagramType.ActivityDiagram)
            {

            }
            else if (diagramType == (int)UML_Creator.ViewModel.EnumDiagramType.ClassDiagram)
            {

                node = new ClassDiagram();
                var window = new UML_Creator.View.AddNewClassDiagramClassWindow();
                window.DataContext = node;
                if (window.ShowDialog() == true)
                {
                    nodes.Add(node);
                }
            }

            else if (diagramType == (int)UML_Creator.ViewModel.EnumDiagramType.InterfaceDiagram)
            {
                node = new InterfaceDiagram() { InterfaceName = "<<>>"};
                var window = new UML_Creator.View.AddNewClassDiagramInterfaceWindow();
                window.DataContext = node;
                if (window.ShowDialog() == true)
                {
                    nodes.Add(node);
                }
            }
        }

        public void UnExecute()
        {
            nodes.Remove(node);
        }

        public void ReExecute()
        {
            nodes.Add(node);
        }
    }
}
